<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <script>
        //  打印出 1 - 10000 之间的所有对称数  例如：121、1331 等

        // 1 菜 写法
        let arr = []
        let flag = false
        for (let i = 1; i < 10001; i++) {
            let cc = i + ''
            if (cc.length<=3&&cc.length>1) {
                // for (let j = 0; j < cc.length; j++) {
                    if (cc[0] == cc[cc.length - 1]) {
                        // console.log(cc)
                        arr.push(cc)
                    }
                // }
            } else if(cc.length==4) {
                // for (let j = 0; j < cc.length; j++) {
                    if (cc[0] == cc[cc.length - 1]&&cc[1]==cc[2]) {
                        // console.log(cc)
                        arr.push(cc)
                    }
                // }
            }
        }
        console.log(arr)
        // 2  66写法
    let dd =  [...Array(10000).keys()].map(x=>x+1).filter(x=>{
         return x.toString().length>1&&x===Number(x.toString().split('').reverse().join(''))
     })
    //  Array()
     console.log(dd)
    </script>
</body>

</html>